/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.site.user.pojo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author zhanjun
 */
@Entity
@Table(name = "tb_privilege")
@NamedQueries({
    @NamedQuery(name = "TbPrivilege.findAll", query = "SELECT t FROM TbPrivilege t"),
    @NamedQuery(name = "TbPrivilege.findByIdResource", query = "SELECT t FROM TbPrivilege t WHERE t.tbPrivilegePK.idResource = :idResource"),
    @NamedQuery(name = "TbPrivilege.findByIdOperator", query = "SELECT t FROM TbPrivilege t WHERE t.tbPrivilegePK.idOperator = :idOperator"),
    @NamedQuery(name = "TbPrivilege.findByIdRole", query = "SELECT t FROM TbPrivilege t WHERE t.tbPrivilegePK.idRole = :idRole"),
    @NamedQuery(name = "TbPrivilege.findByIdSystem", query = "SELECT t FROM TbPrivilege t WHERE t.idSystem = :idSystem")})
public class TbPrivilege implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TbPrivilegePK tbPrivilegePK;
    @Column(name = "ID_SYSTEM")
    private String idSystem;

    public TbPrivilege() {
    }

    public TbPrivilege(TbPrivilegePK tbPrivilegePK) {
        this.tbPrivilegePK = tbPrivilegePK;
    }

    public TbPrivilege(String idResource, String idOperator, String idRole) {
        this.tbPrivilegePK = new TbPrivilegePK(idResource, idOperator, idRole);
    }

    public TbPrivilegePK getTbPrivilegePK() {
        return tbPrivilegePK;
    }

    public void setTbPrivilegePK(TbPrivilegePK tbPrivilegePK) {
        this.tbPrivilegePK = tbPrivilegePK;
    }

    public String getIdSystem() {
        return idSystem;
    }

    public void setIdSystem(String idSystem) {
        this.idSystem = idSystem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tbPrivilegePK != null ? tbPrivilegePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbPrivilege)) {
            return false;
        }
        TbPrivilege other = (TbPrivilege) object;
        if ((this.tbPrivilegePK == null && other.tbPrivilegePK != null) || (this.tbPrivilegePK != null && !this.tbPrivilegePK.equals(other.tbPrivilegePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.site.user.pojo.TbPrivilege[tbPrivilegePK=" + tbPrivilegePK + "]";
    }

}
